#include <stdio.h>
#include <windows.h>

#define MINIQTLIB
#include "qapplication.h"
#include "qicon.h"

struct QIconPrivate {
	HICON hIcon;
};

QIcon::QIcon(QWidget *parent, const char *name)
	: QWidget(parent, name, WType_Child)
{
	d = new QIconPrivate;

	HWND hwnd = CreateWindow(
	    "STATIC",	            		// class name
	    caption(),        	    		// window name
	    WS_VISIBLE|WS_CHILD,  		// style
            CW_USEDEFAULT,	    		// geometry
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
	    parent->winId(),
	    (HMENU)NULL,            		// class menu used
	    hInstance, 	    	    		// instance handle
	    NULL);                  		// no window creation data

	if (hwnd == (HWND)0) {
		fprintf(stderr, "cannot create icon\n");
		exit(1);
	}

	setWinId(hwnd);
	registerWinId(hwnd, this);

	d->hIcon = LoadIcon(NULL, IDI_WINLOGO);
}

QIcon::~QIcon()
{
	delete d;

	unregisterWinId(winId());
	printf("destroing icon %p name=\"%s\"\n", this, name());
}
